package com.gec.hrm.dao.impl;

import com.gec.hrm.pojo.Type;
import com.gec.hrm.pojo.User;
import com.gec.hrm.util.JDBCUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class TypeDaoImpl  extends JDBCUtils<Type> implements TypeDao{
    @Override
    public List<Type> getAllType() {
        return query("select * from type_inf");
    }

    @Override
    public List<Type> listType(int limit,int page) {
        String sql = "select * from type_inf where 1=1 ";//万能条件
//        sql += " limit " + (page - 1) * limit + "," + limit + "";
        List<Type> types = query(sql);
        return types;
    }

    public UserDao userDao=new UserDaoImpl();
    @Override
    public Type getBean(ResultSet rs) {
        Type type = new Type();
        try {
            type.setId(rs.getInt("ID"));
            type.setName(rs.getString("name"));
            type.setState(rs.getInt("state"));
            type.setCreateDate(rs.getDate("create_date"));
            type.setUserId(rs.getInt("user_id"));
            type.setModifyDate(rs.getDate("modify_date"));
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return type;
    }
}
